package org.htmlparser.scanners;

import java.util.Vector;
import org.htmlparser.Attribute;
import org.htmlparser.Node;
import org.htmlparser.NodeFactory;
import org.htmlparser.Tag;
import org.htmlparser.lexer.Lexer;
import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserException;

public class StyleScanner extends CompositeTagScanner
{
  public Tag scan(Tag paramTag, Lexer paramLexer, NodeList paramNodeList)
    throws ParserException
  {
    Node localNode = paramLexer.parseCDATA();
    int i = paramLexer.getPosition();
    Object localObject = paramLexer.nextNode(false);
    if ((localObject != null) && (((!(localObject instanceof Tag)) || (!(((Tag)localObject).isEndTag())) || (!(((Tag)localObject).getTagName().equals(paramTag.getIds()[0]))))))
    {
      paramLexer.setPosition(i);
      localObject = null;
    }
    if (localObject == null)
    {
      Attribute localAttribute = new Attribute("/style", null);
      Vector localVector = new Vector();
      localVector.addElement(localAttribute);
      localObject = paramLexer.getNodeFactory().createTagNode(paramLexer.getPage(), i, i, localVector);
    }
    paramTag.setEndTag((Tag)localObject);
    if (localNode != null)
    {
      paramTag.setChildren(new NodeList(localNode));
      localNode.setParent(paramTag);
    }
    ((Node)localObject).setParent(paramTag);
    paramTag.doSemanticAction();
    return ((Tag)paramTag);
  }
}